package com.hns.can.base.web;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.hns.can.base.entity.SysFuncRegisterEntity;
import com.hns.can.base.service.SysFuncService;
import com.hns.can.common.web.BaseController;
/**
 * 功能资源
 * @author:Fisher
 * @email:zhuangcaijin@126.com
 * @version Revision 2.0.0
 */
@Controller
@RequestMapping("/sysFunc")
public class SysFuncController extends BaseController{
    
    @Autowired
    SysFuncService sysFuncService;//注入sysFuncService
    
    /**
     * @author zy
     * @功能说明：跳转功能树状图
     */
    @RequestMapping("/sysFuncList")
    public ModelAndView sysFuncList()throws Exception{
        return new ModelAndView("base/sysFuncList");
    }
    
    /**
     * @author zy
     * @功能说明：功能资源列表字符串
     */
    @SuppressWarnings("rawtypes")
	@RequestMapping("/getSysFuncList")
    @ResponseBody
    public Object getSysFuncList(
        @ModelAttribute("sysFuncEntity") SysFuncRegisterEntity entity) throws Exception {
        List list = sysFuncService.getSysFuncList(entity);
        return this.getReturnResult(list);
    }

    /**
     * @author zy
     * @功能说明：添加功能资源
     */
    @RequestMapping("/saveSysFunc")
    @ResponseBody
    public Object saveSysFunc (SysFuncRegisterEntity entity) throws Exception {
        sysFuncService.saveSysFunc(entity);
        return this.getReturnResult();
    }
    
    /**
     * @author zy
     * @功能说明：修改功能资源
     */
    @RequestMapping("/updateSysFunc")
    @ResponseBody
    public Object updateSyaFunc(SysFuncRegisterEntity entity){
    	sysFuncService.updateSysFunc(entity);
    	return this.getReturnResult();
    }
    
    
    /**
     * @author zy
     * @功能说明：删除功能资源
     */
    @RequestMapping("/deleteSysFunc")
    @ResponseBody
    public Object deleteSysFunc(HttpServletRequest request) throws Exception {
        String[] ids = request.getParameterValues("ids");
        sysFuncService.deleteSysFunc(ids);
        return this.getReturnResult();
    }
	
}
